﻿layui.use(['form','layer','jquery'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer
        $ = layui.jquery;

    //登录按钮
    var count=0;
    $("#loginBtn").on("click",function(data){
	        $("#loginBtn").text("登录中...").attr("disabled","disabled");
	        $.post("/ssm/login.do",$("#useLogin").serialize(),function(data){
	            if(data.code=='01'){
	            		window.location.href="/ssm/index.html";
	            }else{
	            	count++;
	            	$("#errorCount").val(count);
	                $("#password").val("");
	                $("#loginBtn").text("登录");
	                $('#loginBtn').attr("disabled",false);
	                layer.alert("账号或密码错误");
	                
	            }
	        });
    	return false;
    	
    })

    //表单输入效果
    $(".loginBody .input-item").click(function(e){
        e.stopPropagation();
        $(this).addClass("layui-input-focus").find(".layui-input").focus();
    })
    $(".loginBody .layui-form-item .layui-input").focus(function(){
        $(this).parent().addClass("layui-input-focus");
    })
    $(".loginBody .layui-form-item .layui-input").blur(function(){
        $(this).parent().removeClass("layui-input-focus");
        if($(this).val() != ''){
            $(this).parent().addClass("layui-input-active");
        }else{
            $(this).parent().removeClass("layui-input-active");
        }
    });
    
    /**
     * 验证码点击更换
     */
    $("#imgCaptcha").click(function (){
    	$(this).attr('src', '/system/captchaImage?' + Math.floor(Math.random()*100) );
    });


    
})
